import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @ClassName UserInfoServlet
 * @Description TODO
 * @Author 86181
 * @Date 2022/8/24 21:08
 * @Version 1.0
 **/
public class UserInfoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        String action = req.getParameter("action");
        if ("findAll".equals(action)){
            findAll(req,resp);
        }
    }
    public void findAll(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserInfoImpl info = new UserInfoImpl();
        List<UserInfo> all = info.findAll();
        req.setAttribute("all",all);
        req.getRequestDispatcher("/list.jsp").forward(req,resp);

    }
}
